package com.netease.xone.widget.richtext.span;

import android.text.TextPaint;
import android.text.style.ClickableSpan;
import android.view.View;

import com.netease.xone.widget.richtext.IRichTextClickListener;


public class LinkSpan extends ClickableSpan {
    public static final String REGULAR_LINK = "http://[A-Za-z0-9]+(\\.[A-Za-z0-9]+)+(/([A-Za-z0-9]|[\\.\\+\\*\\(\\(\\?\\$\\-,;:@&=/~#%_!])*)*";
    
    private String mValue;
    private IRichTextClickListener mListener;
    
    public LinkSpan() {
        
    }
    
    public LinkSpan(String value, IRichTextClickListener listener) {
        this.mValue = value;
        this.mListener = listener;
    }
    
    @Override
    public void updateDrawState(TextPaint ds) {
        ds.setUnderlineText(true);
        ds.setColor(ColorEx.BLUE);
    }
    
    @Override
    public void onClick(View view) {
//        Toast.makeText(view.getContext(), "链接", Toast.LENGTH_SHORT).show();
        if (null != mListener) {
            mListener.onRichTextClick(view, mValue, IRichTextClickListener.RICHTEXT_SUBJECT);
        }
    }
}
